package com.seuic.hnjiningposapp.hnapps.ui.view.dialog;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.ToastUtils;
import com.lxj.xpopup.core.CenterPopupView;
import com.seuic.hnjiningposapp.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

public class InputPersonMsgPopup extends CenterPopupView {//输入密码弹窗
    Context context;
    Activity activity;
    Unbinder bind;
    ClickCallback callevent;
    @BindView(R.id.re_input_title)
    TextView reInputTitle;
    @BindView(R.id.re_input_nameedtext)
    EditText reInputNameedtext;
    @BindView(R.id.re_input_numedtext)
    EditText reInputNumedtext;
    @BindView(R.id.re_input_gzbtn)
    Button reInputGzbtn;
    @BindView(R.id.re_input_okbtn)
    Button reInputOkbtn;
    @BindView(R.id.re_input_namelayout)
    LinearLayout reInputNamelayout;
    @BindView(R.id.re_input_numgzbtn)
    Button reInputNumgzbtn;
    @BindView(R.id.re_input_numokbtn)
    Button reInputNumokbtn;
    @BindView(R.id.re_input_numlayout)
    LinearLayout reInputNumlayout;
    @BindView(R.id.re_input_namenumlayout)
    LinearLayout reInputNamenumlayout;
    @BindView(R.id.sure_remittance_title)
    TextView sureRemittanceTitle;
    @BindView(R.id.sure_remittance_num)
    TextView sureRemittanceNum;
    @BindView(R.id.sure_remittance_money)
    TextView sureRemittanceMoney;
    @BindView(R.id.sure_remittance_namea)
    TextView sureRemittanceNamea;
    @BindView(R.id.sure_remittance_gzbtn)
    Button sureRemittanceGzbtn;
    @BindView(R.id.sure_remittance_okbtn)
    Button sureRemittanceOkbtn;
    @BindView(R.id.sure_remittance_layout)
    LinearLayout sureRemittanceLayout;


    public InputPersonMsgPopup(@NonNull Context context, Activity activity, ClickCallback callevent) {
        super(context);
        this.context = context;
        this.activity = activity;
        this.callevent = callevent;
    }

    @OnClick({R.id.sure_remittance_gzbtn, R.id.sure_remittance_okbtn, R.id.re_input_numokbtn, R.id.re_input_gzbtn, R.id.re_input_okbtn, R.id.re_input_namelayout, R.id.re_input_numgzbtn})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.re_input_gzbtn:
                if (reInputOkbtn.getText().toString().equals("下一步")) {
                    reInputNameedtext.setText("");
                } else {
                    reInputNumedtext.setText("");
                }
                break;
            case R.id.re_input_okbtn:
                if (reInputOkbtn.getText().toString().equals("下一步")) {
                    if (reInputNameedtext.getText().toString().equals("")) {
                        ToastUtils.showLong("输入不能为空");
                    } else {
                        reInputNameedtext.setVisibility(View.GONE);
                        reInputNumedtext.setVisibility(View.VISIBLE);
                        reInputTitle.setText("请输入转入人账号");
                        reInputOkbtn.setText("确定");
                    }
                } else {
                    if (reInputNumedtext.getText().toString().equals("")) {
                        ToastUtils.showLong("输入不能为空");
                    } else {
                        sureRemittanceLayout.setVisibility(View.VISIBLE);
                        reInputNamelayout.setVisibility(View.GONE);
                    }
                }
                break;
            case R.id.sure_remittance_gzbtn:
                sureRemittanceLayout.setVisibility(View.GONE);
                reInputNamelayout.setVisibility(View.VISIBLE);
                reInputOkbtn.setText("下一步");
                reInputNamenumlayout.setVisibility(View.VISIBLE);
                reInputNumedtext.setVisibility(View.GONE);
                break;
            case R.id.sure_remittance_okbtn:
                callevent.SendPersonMsg(reInputNameedtext.getText().toString(), reInputNumedtext.getText().toString());
                break;
        }
    }


    public interface ClickCallback {
        void SendPersonMsg(String name, String num);
    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.dialog_inputpersonmsg;
    }

    @Override
    protected void onCreate() {
        super.onCreate();
        bind = ButterKnife.bind(this);
        reInputOkbtn.setText("下一步");
    }


    protected void onShow() {
        super.onShow();
    }

    @Override
    protected void onDismiss() {
        super.onDismiss();
        //注解解绑
        if (bind != null && bind != Unbinder.EMPTY) {
            bind.unbind();
        }
        this.bind = null;
    }
}